//This is the StatsLogon GUI object that represents a viewable panel representing logon controls

//import only what we need to speed things up
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.Image;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Collections;

public class StatsView extends JPanel implements ActionListener {
	
	//declare class instance vars
	private Image background;
	private Image scaledbg;
	private Dimension prevsize;
	private JComboBox vsname_box;
	private JButton clear_btn;
	private JButton goback_btn;
	private JLabel playername_lbl;
	private JLabel playerstats_lbl;
	private JLabel vsstats_lbl;
	private String playername;
	//common colors
	public static Color bgnorm = new Color(188, 143, 70);
	public static Color fgnorm = new Color(56, 5, 3);
	public static Color bgalt1 = new Color(221, 173, 98);
	public static Color fgalt1 = new Color(93, 15, 2);
	public static Color fgalt2 = new Color(242, 79, 1);
	
	//our constructor
	public StatsView() {
		
		//call our ancestor
		super();
		
		//build our layout with GridBag
		//assuming an invisible grid of 14 x 10
		this.setLayout(new GridBagLayout());
		
		//add a filler panel to fill the entire first column (1st-10th row) (1st column)
		JPanel temppan1 = new JPanel();
		temppan1.setOpaque(false);
		temppan1.setVisible(true);
		this.add(temppan1, new GridBagConstraints( 0, 0, 1, 10, 0.1, 1.0, 
			GridBagConstraints.LINE_START, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
			0, 0));
		//add a filler panel to fill the entire first row, sorta (2nd-13th column) (1st row)
		JPanel temppan2 = new JPanel();
		temppan2.setOpaque(false);
		temppan2.setVisible(true);
		this.add(temppan2, new GridBagConstraints( 1, 0, 12, 1, 0.85, 0.05, 
			GridBagConstraints.PAGE_START, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),
			0, 0));
		//add a filler panel to fill the entire last column (1st-10th row) (14th column)
		JPanel temppan3 = new JPanel();
		temppan3.setOpaque(false);
		temppan3.setVisible(true);
		this.add(temppan3, new GridBagConstraints(13, 0, 1, 9, 0.1, 1.0, 
			GridBagConstraints.LINE_END, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
			0, 0));
		//add our main panel to fill up center (2nd-13th column) (2nd-9th row)
		JPanel mainpan = new JPanel();
			//setup another GridBag
			//assuming an invisible grid of 12 x 10
			mainpan.setLayout(new GridBagLayout());
			//add top label to most of the top row (1st-10th column) (1st-2nd row)
			JLabel header1 = new JLabel();
			header1.setText("Game Play Statistics for : ");
			header1.setFont(new Font("Franklin Gothic Heavy", Font.PLAIN, 24));
			header1.setForeground(StatsView.fgnorm);
			mainpan.add(header1, new GridBagConstraints( 0, 0, 10, 2, 1.0, 0.5, 
				GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,10,0,0),
				0, 0));
			//add a filler panel to fill the right of the 3rd row (1st-3rd column) (3rd row)
			JPanel temppan5 = new JPanel();
			temppan5.setOpaque(false);
			temppan5.setVisible(true);
			mainpan.add(temppan5, new GridBagConstraints( 0, 2, 3, 1, 0.8, 0.2, 
				GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),
				0, 0));
			//add player label to center of the 3rd row (4th-8th column) (3rd row)
			this.playername_lbl = new JLabel();
			this.playername_lbl.setFont(new Font("Franklin Gothic Heavy", Font.PLAIN, 20));
			this.playername_lbl.setForeground(StatsView.fgalt1);
			mainpan.add(this.playername_lbl, new GridBagConstraints( 3, 2, 5, 1, 0.3, 0.2, 
				GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),
				0, 0));
			//add vs player drop-down list to right of the 3rd row (9th-12th column) (3rd row)
			this.vsname_box = new JComboBox();
			this.vsname_box.addActionListener(this);
			this.vsname_box.setFont(new Font("Franklin Gothic Heavy", Font.PLAIN, 20));
			mainpan.add(this.vsname_box, new GridBagConstraints( 8, 2, 4, 1, 0.3, 0.2, 
				GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,10),
				0, 0));
			//build stat names label
			String stnames = "<html>" 
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"3\">Total Games</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Wins</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Losses</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Draws</font><br><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Finished</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Unfinished</font><br><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"3\">Total Moves</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Warps</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Jumps</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Kings Created</font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\">Kings Destroyed</font><br>"
				+ "</html>";
			//build stat spacers label
			String stspace = "<html>" 
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"3\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"3\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "<font face=\"Courier New\" color=\"#380503\" size=\"2\"> . </font><br>"
				+ "</html>";
			//setup player stats to left of the remaining rows row (1st-6th column) (4th-10th row)
				JLabel tmpstn1 = new JLabel(stnames);
				JLabel tmpsts1 = new JLabel(stspace);
				JLabel tmpsts2 = new JLabel(stspace);
				JLabel tmpsts3 = new JLabel(stspace);
				//add stat names in the left 2 columns (1st-2nd column) (4th-10th row)
				mainpan.add(tmpstn1, new GridBagConstraints( 0, 3, 2, 7, 0.5, 1.0, 
					GridBagConstraints.LINE_START, GridBagConstraints.VERTICAL, new Insets(0,5,0,0),
					0, 0));
				//add individual stat spacers in the center 3 columns (3rd,4th,5th column) (4th-10th row)
				mainpan.add(tmpsts1, new GridBagConstraints( 2, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				mainpan.add(tmpsts2, new GridBagConstraints( 3, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				mainpan.add(tmpsts3, new GridBagConstraints( 4, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				//add player stats label in the right row (6th column) (4th-10th row)
				this.playerstats_lbl = new JLabel();
				mainpan.add(this.playerstats_lbl, new GridBagConstraints( 5, 3, 1, 7, 0.5, 1.0, 
					GridBagConstraints.LINE_END, GridBagConstraints.VERTICAL, new Insets(0,0,0,5),
					0, 0));
			//setup player stats to right of the remaining rows row (7th-12th column) (4th-10th row)
				JLabel tmpstn2 = new JLabel(stnames);
				JLabel tmpsts4 = new JLabel(stspace);
				JLabel tmpsts5 = new JLabel(stspace);
				JLabel tmpsts6 = new JLabel(stspace);
				//add stat names in the left 2 columns (7th-8th column) (4th-10th row)
				mainpan.add(tmpstn2, new GridBagConstraints( 6, 3, 2, 7, 0.5, 1.0, 
					GridBagConstraints.LINE_START, GridBagConstraints.VERTICAL, new Insets(0,5,0,0),
					0, 0));
				//add individual stat spacers in the center 3 columns (9th,10th,11th column) (4th-10th row)
				mainpan.add(tmpsts4, new GridBagConstraints( 8, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				mainpan.add(tmpsts5, new GridBagConstraints( 9, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				mainpan.add(tmpsts6, new GridBagConstraints( 10, 3, 1, 7, 0.3, 1.0, 
					GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0),
					0, 0));
				//add player stats label in the right row (12th column) (4th-10th row)
				this.vsstats_lbl = new JLabel();
				mainpan.add(this.vsstats_lbl, new GridBagConstraints(11, 3, 1, 7, 0.5, 1.0, 
					GridBagConstraints.LINE_END, GridBagConstraints.VERTICAL, new Insets(0,0,0,5),
					0, 0));
			
		mainpan.setBackground(StatsView.bgalt1);
		mainpan.setOpaque(true);
		mainpan.setVisible(true);
		this.add(mainpan, new GridBagConstraints( 1, 1, 12, 8, 1.0, 0.8, 
			GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),
			0, 0));
		//add a filler panel to fill the entire last row, sorta (2nd-11th column) (10th row)
		JPanel temppan4 = new JPanel();
		temppan4.setOpaque(false);
		temppan4.setVisible(true);
		this.add(temppan4, new GridBagConstraints( 1, 9, 10, 1, 0.85, 0.05, 
			GridBagConstraints.PAGE_END, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),
			0, 0));
		//add our go-back button
		//we want this to be at the bottom right corner cell (10th row) (12th-13th column)
		this.goback_btn = new JButton();
		this.goback_btn.setText("Go Back");
		this.goback_btn.setFont(new Font("Franklin Gothic Heavy", Font.PLAIN, 20));
		this.goback_btn.setBackground(StatsView.bgnorm);
		this.goback_btn.setForeground(StatsView.fgnorm);
		this.goback_btn.setOpaque(true);
		this.goback_btn.setVisible(true);
		this.goback_btn.addActionListener(this);
		this.add(this.goback_btn, new GridBagConstraints(11, 9, 2, 1, 0.0, 0.0, 
			GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0,0,0,0),
			0, 0));
			
		
		//set a reasonable size to match the ratio of our splash image
		this.setPreferredSize(new Dimension(500, 375));
		
		//try to get our splash image
		//if we cannot retrieve the image, it is somewhat serious
		//but I don't know what we could do from that point on :(
		try{
			background = ImageIO.read(new File("images\\SplashMedium.jpg"));
		}catch (IOException EXC){
			//this likely means there was some problem accessing the image file
		}catch (IllegalArgumentException EXC){
			//this likely means that for some reason we couldn't create the File object
		}
		
		//setup our text etc defaults
		//tbc
		//this.setPlayer("Default Player");
		ArrayList<String> tmpvsplayers = new ArrayList<String>();
			tmpvsplayers.add("Default Player");
			//this.setVSPlayers(tmpvsplayers);
		this.setPlayerStats(10,5,3,1,9,1,300,57,23,2,4);
		this.setVSStats(10,5,3,1,9,1,300,57,23,2,4);
		
		//setup visibilities
		this.setVisible(true);
		this.setOpaque(true);
		
	}
	
	//override this so that we can customize drawing of the component
	//specifically so that we always have our pretty splash screen behind us :D
	public void paintComponent(Graphics g) {
		
		//call our ancestor
		super.paintComponent(g);
		
		System.out.println("$1GameLogon: painting...");
		
		//getSize is a retarded method, as such it requires
		//  we pass a Dimension object that it will use by referrence to store the size
		//the retarded part is that it also returns the same Dimension object
		//  go figure...
		Dimension panelsize = new Dimension(0,0);
		this.getSize(panelsize);
		
		//check if previous size has been declared yet
		if (this.prevsize == null){
			this.prevsize = new Dimension(panelsize);
		}
		
		//check if we need to rescale the image
		// this can occur if the component size changed
		// or it can occur if the image has not been scaled yet
		if (this.scaledbg == null || !panelsize.equals(this.prevsize)){
			this.scaledbg = background.getScaledInstance(panelsize.width,
			panelsize.height, Image.SCALE_SMOOTH);
		}
		g.drawImage(scaledbg, 0, 0, null);
		
		//reset the previous scale size
		this.prevsize = new Dimension(panelsize);
		
	}
	
	
	//method used to set our current player
	public void setPlayer(String newplayername) {
		
		this.playername = newplayername;
		this.playername_lbl.setText(this.playername + " AND: ");
		this.getPlayerStats();
		
	}
	
	//hidden convenience method for adding the VS player names to the drop-down list
	private void setVSPlayers(ArrayList<String> newvsplayers) {
		
		//dont do anything if the list is empty
		if (newvsplayers.isEmpty()){
			return;
		}
		//for user convenience, we should make sure the list is sorted
		//lets have fun and try the java default algorithm
		if (newvsplayers.size() > 1){
			Collections.sort(newvsplayers);
		}
		this.vsname_box.removeAllItems();
		for (int i=0; i<newvsplayers.size(); ++i){
			this.vsname_box.addItem(new VSPlayer(newvsplayers.get(i)));
		}
		
	}
	//convenience method for retrieving player data from Storage
	public void getPlayers() {
		
		this.setVSPlayers(UIController.getUsers());
		
	}
	
	
	//hidden convenience method for setting the statistics of the current player
	/*
	int gamestotal          int movestotal    
	int wins                int warps         
	int losses              int jumps         
	int draws               int kingscreated  
	int finished            int kingsdestroyed
	int unfinished
	*/
	private void setPlayerStats(ArrayList<Integer> stats) {
		
		//make sure we have enough data to build from
		if (stats.size() < 11){
			return;
		}
		//default, 5d0f02
		String txtdetail = "<html>" 
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"3\">" + stats.get(0) + "</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(1),stats.get(0)) + " (" + stats.get(1) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(2),stats.get(0)) + " (" + stats.get(2) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(3),stats.get(0)) + " (" + stats.get(3) + ")</font><br><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(4),stats.get(0)) + " (" + stats.get(4) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(5),stats.get(0)) + " (" + stats.get(5) + ")</font><br><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"3\">" + stats.get(6) + "</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(7),stats.get(6)) + " (" + stats.get(7) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(8),stats.get(6)) + " (" + stats.get(8) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(9),stats.get(6)) + " (" + stats.get(9) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(10),stats.get(6)) + " (" + stats.get(10) + ")</font><br>"
			+ "</html>";
		this.playerstats_lbl.setText(txtdetail);
		
	}
	private void setPlayerStats(int gamestotal, int wins, int losses, int draws, int finished, int unfinished, 
		int movestotal, int warps, int jumps, int kingscreated, int kingsdestroyed) {
		
		ArrayList<Integer> tmpstats = new ArrayList<Integer>();
		tmpstats.add(new Integer(gamestotal));
		tmpstats.add(new Integer(wins));
		tmpstats.add(new Integer(losses));
		tmpstats.add(new Integer(draws));
		tmpstats.add(new Integer(finished));
		tmpstats.add(new Integer(unfinished));
		tmpstats.add(new Integer(movestotal));
		tmpstats.add(new Integer(warps));
		tmpstats.add(new Integer(jumps));
		tmpstats.add(new Integer(kingscreated));
		tmpstats.add(new Integer(kingsdestroyed));
		this.setPlayerStats(tmpstats);
		
	}
	//hidden convenience method for getting the statistics of the current player
	private void getPlayerStats() {
		
		if (this.playername != null){
			String tmpusrname = this.playername;
			ArrayList<Integer> tmpstat = UIController.getUserStats(tmpusrname);
			if (tmpstat != null){
				this.setPlayerStats(tmpstat);
			}else{
				//this.showInfoNotice("No statistics found for the account of " + tmpusrname, "No Stats to Display");
				System.out.println("no stats found for " + tmpusrname);
			}
		}
		
	}
	
	//hidden convenience method for setting the statistics of the VS player
	private void setVSStats(ArrayList<Integer> stats) {
		
		//make sure we have enough data to build from
		if (stats.size() < 11){
			return;
		}
		//default, 5d0f02
		String txtdetail = "<html>" 
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"3\">" + stats.get(0) + "</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(1),stats.get(0)) + " (" + stats.get(1) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(2),stats.get(0)) + " (" + stats.get(2) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(3),stats.get(0)) + " (" + stats.get(3) + ")</font><br><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(4),stats.get(0)) + " (" + stats.get(4) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(5),stats.get(0)) + " (" + stats.get(5) + ")</font><br><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"3\">" + stats.get(6) + "</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(7),stats.get(6)) + " (" + stats.get(7) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(8),stats.get(6)) + " (" + stats.get(8) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(9),stats.get(6)) + " (" + stats.get(9) + ")</font><br>"
			+ "<font face=\"Courier New\" color=\"#5d0f02\" size=\"2\">" + this.getPercentage(stats.get(10),stats.get(6)) + " (" + stats.get(10) + ")</font><br>"
			+ "</html>";
		this.vsstats_lbl.setText(txtdetail);
		
	}
	private void setVSStats(int gamestotal, int wins, int losses, int draws, int finished, int unfinished, 
		int movestotal, int warps, int jumps, int kingscreated, int kingsdestroyed) {
		
		ArrayList<Integer> tmpstats = new ArrayList<Integer>();
		tmpstats.add(new Integer(gamestotal));
		tmpstats.add(new Integer(wins));
		tmpstats.add(new Integer(losses));
		tmpstats.add(new Integer(draws));
		tmpstats.add(new Integer(finished));
		tmpstats.add(new Integer(unfinished));
		tmpstats.add(new Integer(movestotal));
		tmpstats.add(new Integer(warps));
		tmpstats.add(new Integer(jumps));
		tmpstats.add(new Integer(kingscreated));
		tmpstats.add(new Integer(kingsdestroyed));
		this.setVSStats(tmpstats);
		
	}
	//hidden convenience method for getting the statistics of the VS player
	private void getVSStats() {
		
		if (this.vsname_box.getSelectedItem() != null){
			String tmpusrname = ((VSPlayer)(this.vsname_box.getSelectedItem())).username;
			ArrayList<Integer> tmpstat = UIController.getUserStats(tmpusrname);
			if (tmpstat != null){
				this.setVSStats(tmpstat);
			}else{
				//this.showInfoNotice("No statistics found for the account of " + tmpusrname, "No Stats to Display");
				System.out.println("no stats found for " + tmpusrname);
			}
		}
		
	}
	
	//hidden convenience method for getting the text percentage of 2 Integer objects
	private String getPercentage(Integer numerator, Integer denominator) {
		
		String percentage = "0%";
		try{
			percentage = "" + (int)Math.ceil(100 * (double)numerator.intValue() / (double)denominator.intValue()) + "%";
		}catch (ArithmeticException EXC){}
		return percentage;
		
	}
	
	//hidden convenience method for showing the user an information notice
	private void showInfoNotice(String info, String title) {
		
		this.repaint();
		JOptionPane.showMessageDialog(this, info, title, JOptionPane.INFORMATION_MESSAGE);
		
	}
	
	
	//implement ActionListener
	public void actionPerformed(ActionEvent EVE) {
		
		//determine the caller
		Object tmpobj = EVE.getSource();
		if (tmpobj.equals(this.goback_btn)){
			UIController.changeState("MainView");
		}else if (tmpobj.equals(this.vsname_box)){
			//get stats for selected player
			this.getVSStats();
		}
		
	}
	
	//hidden internal convenience class representing a VS player
	// required to help eliminate a potential bug if we receive 2 VS players having the same username
	private class VSPlayer {
		
		private String username;
		
		public VSPlayer(String newusername) {
			
			this.username = newusername;
			
		}
		
		public String toString() {
			
			return this.username;
			
		}
		
	}
	
	
}